﻿using System;
using System.Collections.Generic;
using DDDNorthWind.AC.ImportProducts.Domain.Aggregate;
using DDDNorthWind.AC.ImportProducts.Domain.ValueObjects;
using DDDNorthWind.Core.Domain.Aggregate;
using DDDNorthWind.Core.Domain.Events;
using DDDNorthWind.Core.Domain.Identity;

namespace DDDNorthWind.AC.ImportProducts.Domain.Entities
{
    public sealed class ImportSupplier : AggregateRoot<ImportSupplierId,Guid>, IImportAggregate
    {
        public ImportSupplier(ImportSupplierId id)
            : base(id)
        {
            Products = new HashSet<ImportProduct>();
        }

        //public ImportSupplier():base(new DefaultGuidIdentifierGenerator())
        //{
        //}

        public ISet<ImportProduct> Products{get; private set;}
        

        public void AddProduct(ImportProduct importProduct)
        {
            Products.Add(importProduct);
        }


        protected override void CreateNewIdentity(IUniqueIdentifierGenerator<Guid> uniqueIdentifierGenerator)
        {
            Id = new ImportSupplierId(uniqueIdentifierGenerator.GetNewId());
        }

        public override ImportSupplierId Id { get; protected set; }
        protected override void RegisterAggregateEvents()
        {
            throw new NotImplementedException();
        }
    }
}